<template>
  <!-- 自定义Dialog -->
  <van-overlay :show="fatherProps.statusShow || statusShow">
    <div class="dialog" @click.stop>
      <p class="content">{{ fatherProps.message }}</p>
      <div class="button-group">
        <button class="custom-cancle" @click="handleCancel"><p>取消</p></button>
        <button class="custom-verify" @click="handleVerify">确定</button>
      </div>
    </div>
  </van-overlay>
</template>
<script lang="ts" setup name="CustomDialog">
import type { Ref } from "vue";
import { ref, inject, watch } from "vue";
/**
 * @statusMsg {String} 控制显示的字体内容
 * @statusShow {Boolean} 控制显示隐藏
 * @verify {Function} 点击确认执行的函数
 */
const verify: any = inject("verify");
const emit = defineEmits(["update-status"]);
const fatherProps = defineProps({
  statusShow: Boolean,
  message: String,
});
const statusShow: Ref<boolean> = ref(fatherProps.statusShow);

watch(
  () => fatherProps.statusShow,
  (newValue) => {
    statusShow.value = newValue;
  }
);

const handleCancel = (): void => {
  const newValue = false;
  emit("update-status", newValue);
};

const handleVerify = (): void => {
  emit("update-status", verify());
};
</script>
<style lang="less" scoped>
.dialog {
  width: 420px;
  height: 240px;
  background-color: #fff;

  .content {
    width: 100%;
    font-size: 26px;
    box-sizing: border-box;
    padding: 41px 65px 0 65px;
    text-align: center;
    color: #333;
  }

  .button-group {
    width: 100%;
    margin-top: 26px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    padding: 0 25px 39px 34px;
  }
}

.custom-cancle {
  width: 168px;
  height: 60px;
  border-radius: 16px;
  border: 1px solid #87f4df;
  color: #49cb96;
  font-size: 26px;
  background: linear-gradient(90deg, @start-btnbgc 0%, @end-btnbgc 100%);
  opacity: 0.2;
}

.custom-verify {
  width: 173px;
  height: 60px;
  background: linear-gradient(90deg, @start-btnbgc 0%, @end-btnbgc 100%);
  border-radius: 16px;
  font-size: 26px;
  color: #333333;
}
</style>
